home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / tcl / expecTerm / unit_random.c < prev    next >
Encoding:
Text File  |  1993-11-17  |  606 b   |  26 lines  |  [TEXT/MPS ]

  1. /* unit_random.c - compute random numbers from 0 to 1, for expect's send -h
  2.  
  3. Written by: Don Libes, NIST, 10/31/89
  4.  
  5. Design and implementation of this program was paid for by U.S. tax
  6. dollars.  Therefore it is public domain.  However, the author and NIST
  7. would appreciate credit if this program or parts of it are used.
  8.  
  9. */
  10.  
  11. /* This implementation sacrifices beauty for portability */
  12.  
  13. void
  14. init_unit_random()
  15. {
  16.     srand(getpid());
  17. }
  18.  
  19. float
  20. unit_random()
  21. {
  22.     /* current implementation is pathetic but works */
  23.     /* 99991 is largest prime in my CRC - can't hurt, eh? */
  24.     return((float)(rand()%99991)/99991.0);
  25. }
  26.